public class Purchasing extends Observation{

	private ReceivingStock obsSubject;
	
	public Purchasing(ReceivingStock s){
		obsSubject=s;
	}
	
	public void buy(Part t, int count){
		obsSubject.insert(t, count);
	}
	
	public void alarm(Part t){
		int q = obsSubject.getMinStockItems();
		int w = obsSubject.getMaxStockItems();
		int diff = w-obsSubject.get(t);
		if(q>obsSubject.get(t)){
			buy(t, diff);
		}
	}
	
}
